package jp.go.aist.six.test.util.castor;

import java.util.Arrays;
import jp.go.aist.six.util.search.Aggregation;
import jp.go.aist.six.util.search.AndBinding;
import jp.go.aist.six.util.search.Binding;
import jp.go.aist.six.util.search.Function;
import jp.go.aist.six.util.search.InBinding;
import jp.go.aist.six.util.search.LikeBinding;
import jp.go.aist.six.util.search.Limit;
import jp.go.aist.six.util.search.NotBinding;
import jp.go.aist.six.util.search.NullBinding;
import jp.go.aist.six.util.search.OrBinding;
import jp.go.aist.six.util.search.Order;
import jp.go.aist.six.util.search.PropertyProjection;
import jp.go.aist.six.util.search.Relation;
import jp.go.aist.six.util.search.RelationalBinding;
import jp.go.aist.six.util.search.SearchCriteria;
import jp.go.aist.six.util.search.TextMatchBinding;





/**
 * @author  Akihito Nakamura, AIST
 * @version $Id: SampleCriteria.java 318 2011-06-16 03:09:31Z nakamura5akihito $
 */
public class SampleCriteria
{

    /**
     */
    public SampleCriteria()
    {
    }



    //==============================================================
    //  elements of criteria
    //==============================================================

    public static final Binding  BINDING_NULL_1 = new NullBinding( "p" );
    public static final Binding  BINDING_NULL_2 = new NullBinding( "p", true );

    public static final Binding  BINDING_LIKE_1 = new LikeBinding( "p", "abc%" );

    public static final Binding  BINDING_RELATIONAL_1 =
        RelationalBinding.equalBinding( "p", "abc" );
    public static final Binding  BINDING_RELATIONAL_2 =
        RelationalBinding.notEqualBinding( "p", "abc" );

    public static final Binding  BINDING_IN_1 =
        new InBinding( "p", new String[] { "abc", "def", "ghi" } );

    public static final Binding  BINDING_IN_2 =
        new InBinding( "p", new String[] { "abc", "def", null, "ghi" } );

    public static final Binding  BINDING_IN_3 =
        new InBinding( "p", new Object[] { Relation.GREATER_EQUAL, Relation.LESS_THAN } );

    public static final Binding  BINDING_IN_4 =
        new InBinding( "p", new Integer[] {
                                        Integer.parseInt( "100" ),
                                        null,
                                        Integer.parseInt( "222" ),
                                        Integer.parseInt( "33" )
        } );

    public static final Binding  BINDING_IN_5 =
        new InBinding( "p", new SimpleEnum[] {
                                        SimpleEnum.A,
                                        SimpleEnum.C
        } );



    public static final Binding  BINDING_AND_1 =
        new AndBinding( BINDING_NULL_2, BINDING_RELATIONAL_1 );

    public static final Binding  BINDING_OR_1 =
        new OrBinding( new Binding[] {
                        BINDING_NULL_1,
                        BINDING_RELATIONAL_2,
                        BINDING_IN_1
                        } );

    public static final Binding  BINDING_NOT_1 =
        new NotBinding( BINDING_RELATIONAL_1 );
    public static final Binding  BINDING_NOT_2 =
        new NotBinding( BINDING_AND_1 );

//    public static final FulltextMatch  MATCH_1 =
//        new FulltextMatch(
//                        new String[] { "p", "q", "r" },
//                        new String[] { "abc", "def" }
//                        );

    public static final Order  ORDER_1 = new Order( "p" );
    public static final Order  ORDER_2 = new Order( "q", true );

    public static final Limit  LIMIT_1 = new Limit( 10 );
    public static final Limit  LIMIT_2 = new Limit( 10, 100 );

    public static final PropertyProjection  PROJECTION_1 =
        new PropertyProjection( "p" );
    public static final Aggregation  PROJECTION_2 =
        new Aggregation( "p", Function.MAX );
    public static final Aggregation  PROJECTION_3 =
        new Aggregation( "p", Function.COUNT );

    public static final TextMatchBinding  BINDING_TEXT_MATCH_1 =
        new TextMatchBinding(
                        "p",
                        Arrays.asList( "abc", "def" )
                        );



    //==============================================================
    //  criteria
    //==============================================================

    public static final SearchCriteria  CRITERIA_1 =
        new SearchCriteria();

    public static final SearchCriteria  CRITERIA_2 =
        (new SearchCriteria()).setBinding( BINDING_AND_1 );

    public static final SearchCriteria  CRITERIA_3 =
        (new SearchCriteria()).setBinding( BINDING_AND_1
                        ).addOrder( ORDER_1 ).addOrder( ORDER_2 );

    public static final SearchCriteria  CRITERIA_4 =
        (new SearchCriteria()).setBinding( BINDING_OR_1
                        ).addOrder( ORDER_1 ).addOrder( ORDER_2
                                        ).setLimit( LIMIT_1 );

    public static final SearchCriteria  CRITERIA_5 =
        (new SearchCriteria()).setBinding( BINDING_AND_1
                        ).addOrder( ORDER_1 ).addOrder( ORDER_2
                                        ).setLimit( LIMIT_2
                                                        ).addProjection( PROJECTION_1 ).addProjection( PROJECTION_2
                                                                        ).setDistinct( false );

    public static final SearchCriteria  CRITERIA_6 =
        (new SearchCriteria()).setBinding( BINDING_AND_1
                        ).addOrder( ORDER_1 ).addOrder( ORDER_2
//                                        ).setFulltextMatch( MATCH_1
                                        ).setLimit( LIMIT_2
                                                        ).addProjection( PROJECTION_1 ).addProjection( PROJECTION_2
                                                                        ).setDistinct( false );
    public static final SearchCriteria  CRITERIA_7 =
        (new SearchCriteria()).setBinding( BINDING_TEXT_MATCH_1 );

    public static final SearchCriteria  CRITERIA_8 =
        (new SearchCriteria()).setBinding( BINDING_IN_4 );

    public static final SearchCriteria  CRITERIA_9 =
        (new SearchCriteria()).setBinding( BINDING_IN_5 );


}
// SampleCriteria

/* vim:set tabstop=4:set expandtab:set shiftwidth=4: */

